import { useState, useEffect } from "react";
import { Position } from "./usePointerPosition";

function useDelayedValue(value: Position, delay: number) {
  const [position, setPosition] = useState<Position>(value);

  useEffect(() => {
    setTimeout(() => {
      setPosition(value);
    }, delay);
  }, [value, delay]);

  return position;
}

export default useDelayedValue;
